<?php
/**
 * Formulaire de consultation de news
 * @author Etienne AUDOUIN <etienne.audouin@ingesup.com>
 * @author Adrien MARIANELLI <adrien.marianelli@ingesup.com>
 * @version 1.0
 * @package view_news_read
 */
if (isset($idLetter) && $idLetter != 0)
    $selected = $idLetter;
else
    $selected = 'default';

echo form_open();
echo form_fieldset('Show Newsletter');
echo '<table id="table_newsletter">';
echo '<tr>';
echo '<th>Choose Newsletter</th>';
echo '<td>' . form_dropdown('select_newsletter', $titles, $selected) . '</td>';
echo '</tr>';
echo '</table>';
echo form_submit(null, 'Display');
if (isset($idLetter) && $idLetter != 0) {
    // Pk ca va pas a gauche le texte ?!
    echo '<div id="newsletterDisplay">';
    echo '<h2>' . $newsletters[$idLetter]['title'] . '</h2>';
    echo '<p>' . $newsletters[$idLetter]['content'] . '</p>';
    echo '<p>' . $newsletters[$idLetter]['signature'] . '</p>';
    echo '<br />';
    echo '<p>To mailinglists : ';
    $displayList = '';
    foreach ($lists as $list){
        foreach(explode(':', $newsletters[$idLetter]['id_mailinglists']) as $mailinglist) {
            if ($mailinglist == $list['id'])
                $displayList .= $list['name'] . ' - ';
        }
    }
    echo $displayList = substr($displayList, 0, strlen($displayList) - 3);
    echo '</p>';
    echo '</div>';
}
echo form_fieldset_close();
echo form_close();
?>